from sklearn.cross_validation import cross_val_score
from Evaluation.DataProcess import read_data_for_mmatrix
from sklearn.datasets import load_svmlight_file
from sklearn import svm


def calculate_f_measure(data, tag):
    return cross_val_score(estimator=svm.LinearSVC(), X=data, y=tag, cv=5)


if __name__ == "__main__":
    root = "G:/experiment/revert_lda/news/"
    # data, tag = read_data_for_mmatrix(root+"LDA_0.1_0.01_100/0/model-final.phi.T",root+"news.tag.T")
    data,tag =load_svmlight_file("C:/Users/ffftzh/Desktop/liblinear-2.1/windows/model-final.phi.T.csv.svm")
    print(calculate_f_measure(data,tag))